package com.holly.unit.bpmn.designer.core.strategy;

import cn.hutool.core.collection.ListUtil;
import com.holly.unit.bpmn.designer.constants.BpmnDesignerConstants;
import com.holly.unit.bpmn.designer.core.bpmn.BpmnModelFactory;
import com.holly.unit.bpmn.designer.enums.ApprovalModeEnum;
import com.holly.unit.bpmn.designer.model.ChildNode;
import org.activiti.bpmn.model.UserTask;


/**
 * 类描述: 手动输入  用户策略
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/5/13 9:16
 */
public class CreateInputUsersTaskStrategy implements CreateTaskStrategy{

    @Override
    public UserTask createTask(ChildNode node, BpmnModelFactory factory) {

        UserTask userTask =null;
        // 会签任务
        if (node.getProperties().getOptionalMultiUser().equals(ApprovalModeEnum.COUNTER_SIGN.fieldName())) {
            userTask = factory.createCountersignAssigneeTask(node.getNodeId(),node.getProperties().getTitle(),
                    BpmnDesignerConstants.COUNTER_SIGN_ASSIGNEE_NAME,
                    BpmnDesignerConstants.COUNTER_SIGN_COMPLTE_CONDITION,
                    node.getProperties().getExpression());
        } else if (node.getProperties().getOptionalMultiUser().equals(ApprovalModeEnum.OR_SIGN.fieldName())) {//或签任务
            userTask = factory.createCandidateUsersTask(node.getNodeId(),node.getProperties().getTitle(), ListUtil.of(node.getProperties().getExpression()));
        } else if (node.getProperties().getOptionalMultiUser().equals(ApprovalModeEnum.NEXT_SIGN.fieldName())) {//顺序签
            // TODO 顺序签
        }
        return userTask;
    }
}
